<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<link rel="stylesheet" type="text/css" href="css/index.css"/>
	<title>登录</title>
	<style type="text/css">html,
body {
	width: 100%;
	height: 100%;
}</style>
</head>
<body>
	<div class="login">
		<div class="loginbox">
			<div class="loginbox1">
				<div class="logintitle">商城用户登录</div>
				<div class="loginform">
					<div class="user"><p class="logpic"><img src="img/user.png" alt="" class="loginicon" /></p><input id="telphone" type="text" placeholder="请输入用户名" class="logginpt" /></div>
					<div class="user"><p class="logpic"><img src="img/mima.png" alt="" class="loginicon" /></p><input id="password" type="password" placeholder="请输入密码" class="logginpt" /></div>
					<div class="btn">
						<div id="login" class="btn1" onclick="">登录</div>
						<div class="btn2" onclick="window.location.href='register.html'">注册</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
<script src="js/Global.js"></script>
<script src="js/jquery-1.11.0.js"></script>
		<script type="application/javascript">jQuery(document).ready(function() {
	//绑定otp的click时间用于向后段发送获取手机验证码请求。
	$("#login").on("click", function() {
		var telphone = $("#telphone").val();
		$.ajax({
			type: "post",
			url: requesturl + "user/login",
			async: false,
			data: {
				"telphone": $("#telphone").val(),
				"password": $("#password").val()
			},
			xhrFields: {
				withCredentials: true
			},
			success: function(data) {
				if(data.status == "success") {
					var prevLink = document.referrer;
					var home = "./index.html"
					if($.trim(prevLink) == '') {
						location.href = home
					} else {
						if(prevLink.indexOf('http://localhost/kuche/web/') == -1) { //来自其它站点  
							location.href = home;
						}
						if(prevLink.indexOf('register.html') != -1) { //来自注册页面  
							location.href = home;
						}
						location.href = prevLink;
					}
					window.location.href = "./index.html";

				} else {
					alert("登录失败：" + data.data.errMsg);
				}
			},
			error: function(data) {
				alert("网络原因发送失败：" + data.responseText);
			}
		});
	});
});</script>